/**
 * 装饰器模式
 * ES7新语法
 */

class Person {
    constructor(name) {
        this.name = name
    }

    @Readonly
    getName() {
        return this.name
    }
}

function Readonly(target, name, descriptor) {
    descriptor.writable = false
}

const p = new Person('lihua')
console.log(p.getName());
p.getName = function () {
    return 'new name'
}
console.log(p.getName());

